﻿/********************************************************************************
** @ Date:2023/11/22
** @ Author: Gaojia
** @ Description: 自定义表格控件B
** @ Version:1.0.0
** @ Fun:
********************************************************************************/
#ifndef CTableWidgetB_H
#define CTableWidgetB_H
#include <qtablewidget.h>
#include <QLabel>
#include <QPushButton>
#include <QHeaderView>
#include <QVector>

class CPdfRptInterface;
class CTableWidgetB :
	public QTableWidget
{
	Q_OBJECT
		/**
		* @ Author: Gaojia
		* @ Description:  任务信息对象
		*/
		struct MyStructTask
	{
		QLabel    *     m_pLabIndex = nullptr;     //序号
		QLabel    *     m_pLabTaskName = nullptr;  //任务名称
		QLabel    *     m_pLabBeginTime = nullptr; //执行时间
		QLabel    *     m_pLabCountAll = nullptr;  //总项数
		QLabel    *     m_pLabCountGood = nullptr; //正常项数
		QLabel    *     m_pLabCountFail = nullptr; //失败项数
		QLabel    *     m_pLabCountFailCollect = nullptr; //持续巡检项失败项数
		QLabel    *     m_pLabTaskStatus = nullptr; //任务执行状态
		QPushButton *   m_pBtnView = nullptr;      //查询明细
		QPushButton *   m_pBtnPdfReport = nullptr; //查询pdf报表
		QPushButton *   m_pBtnSyncPdfReport = nullptr; //查询pdf综合报表
		QPushButton *   m_pBtnReCreRpbPdfRpt = nullptr;//重新生成机器人报表
		MyStructTask()
		{
			m_pLabIndex = new QLabel();
			m_pLabTaskName = new QLabel();
			m_pLabBeginTime = new QLabel();
			m_pLabCountAll = new QLabel();
			m_pLabCountGood = new QLabel();
			m_pLabCountFail = new QLabel();
			m_pLabCountFailCollect = new QLabel();
			m_pLabTaskStatus = new QLabel();
			m_pBtnView = new QPushButton();
			m_pBtnPdfReport = new QPushButton();//查询pdf报表
			m_pBtnSyncPdfReport = new QPushButton();//综合报表查询按钮
			m_pBtnReCreRpbPdfRpt = new QPushButton();//重新生成机器人报表
			m_pLabIndex->setAlignment(Qt::AlignCenter);
			m_pLabTaskName->setAlignment(Qt::AlignCenter);
			m_pLabBeginTime->setAlignment(Qt::AlignCenter);
			m_pLabCountAll->setAlignment(Qt::AlignCenter);
			m_pLabCountGood->setAlignment(Qt::AlignCenter);
			m_pLabCountFail->setAlignment(Qt::AlignCenter);
			m_pLabCountFailCollect->setAlignment(Qt::AlignCenter);
			m_pLabTaskStatus->setAlignment(Qt::AlignCenter);
			m_pBtnView->setText(QString::fromLocal8Bit("查看明细"));
			m_pBtnReCreRpbPdfRpt->setText(QString::fromLocal8Bit("重新生成机器人报表"));
			m_pLabIndex->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabTaskName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabBeginTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabCountAll->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabCountGood->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabCountFail->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabCountFailCollect->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabTaskStatus->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			//m_pBtnView->setStyleSheet("QPushButton:hover { background-color:  rgba(85, 255, 127,150); };background-color: transparent;color: rgb(0, 0, 0);border: none;");
			m_pBtnPdfReport->setStyleSheet("QPushButton {"
				"    background-image: url(:/icon/Rob/pdf.png);"
				"    background-repeat: no-repeat;"
				"    background-position: center;"
				"    border: 3px solid transparent;/* 调整这里的数值以设置预留的距离 */"
				"}");//查询pdf报表
			m_pBtnSyncPdfReport->setStyleSheet("QPushButton {"
				"    background-image: url(:/icon/Rob/pdf.png);"
				"    background-repeat: no-repeat;"
				"    background-position: center;"
				"    border: 3px solid transparent;/* 调整这里的数值以设置预留的距离 */"
				"}");//查询pdf综合报表
			
		}
	};

	/**
	* @ Author: Gaojia
	* @ Description: 巡检点信息对象
	*/
	struct MyStructPoint
	{
		QLabel    *     m_pLabIndex;     //序号
		QLabel    *     m_pLabTaskName;  //任务名称
		QLabel    *     m_pLabPointName;  //任务名称
		QLabel    *     m_pLabBeginTime; //执行时间
		QLabel    *     m_pLabCountAll;  //总项数
		QLabel    *     m_pLabCountGood; //正常项数
		QLabel    *     m_pLabCountFail; //失败项数
		QPushButton *   m_pBtnView;      //查询明细
		MyStructPoint()
		{
			m_pLabIndex = new QLabel();
			m_pLabTaskName = new QLabel();
			m_pLabPointName = new QLabel();
			m_pLabBeginTime = new QLabel();
			m_pLabCountAll = new QLabel();
			m_pLabCountGood = new QLabel();
			m_pLabCountFail = new QLabel();
			m_pBtnView = new QPushButton();
			m_pLabIndex->setAlignment(Qt::AlignCenter);
			m_pLabTaskName->setAlignment(Qt::AlignCenter);
			m_pLabPointName->setAlignment(Qt::AlignCenter);
			m_pLabBeginTime->setAlignment(Qt::AlignCenter);
			m_pLabCountAll->setAlignment(Qt::AlignCenter);
			m_pLabCountGood->setAlignment(Qt::AlignCenter);
			m_pLabCountFail->setAlignment(Qt::AlignCenter);
			m_pBtnView->setText(QString::fromLocal8Bit("查看明细"));
			m_pLabIndex->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabTaskName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabPointName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabBeginTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabCountAll->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabCountGood->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabCountFail->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
		}
	};

	/**
	* @ Author: Gaojia
	* @ Description: 巡检项信息对象
	*/
	struct MyStructItem
	{
		QLabel    *     m_pLabIndex;     //序号
		QLabel    *     m_pLabTaskName;  //任务名称
		QLabel    *     m_pLabPointName; //巡检点名称
		QLabel    *     m_pRollerNo; //托辊号
		QLabel    *     m_pLabItemName;  //巡检项名称
		QLabel    *     m_pLabDeviceType;  //设备类型
		QLabel    *     m_pLabBeginTime; //执行时间
		QLabel    *     m_pLabActType;   //执行方式
		QLabel    *     m_pLabResult;    //执行结果
		QLabel    *     m_pLabAlarmVal;  //报警预制
		QLabel *   m_pBtnImage;     //预览图
		QPushButton *   m_pBtnView;      //查询明细
		MyStructItem()
		{
			m_pLabIndex = new QLabel();
			m_pLabTaskName = new QLabel();
			m_pLabPointName = new QLabel();
			m_pRollerNo = new QLabel();
			m_pLabItemName = new QLabel();
			m_pLabDeviceType = new QLabel();
			m_pLabBeginTime = new QLabel();
			m_pLabActType = new QLabel();
			m_pLabResult = new QLabel();
			m_pLabAlarmVal = new QLabel();
			//m_pBtnImage = new QPushButton();
			m_pBtnImage = new QLabel();
			m_pBtnView = new QPushButton();

			m_pLabIndex->setAlignment(Qt::AlignCenter);
			m_pLabTaskName->setAlignment(Qt::AlignCenter);
			m_pLabPointName->setAlignment(Qt::AlignCenter);
			m_pRollerNo->setAlignment(Qt::AlignCenter);
			m_pLabItemName->setAlignment(Qt::AlignCenter);
			m_pLabBeginTime->setAlignment(Qt::AlignCenter);
			m_pLabActType->setAlignment(Qt::AlignCenter);
			m_pLabResult->setAlignment(Qt::AlignCenter);
			m_pLabAlarmVal->setAlignment(Qt::AlignCenter);
			m_pBtnImage->setAlignment(Qt::AlignCenter);
			m_pLabDeviceType->setAlignment(Qt::AlignCenter);
			m_pBtnView->setText(QString::fromLocal8Bit("查看明细"));
			m_pLabIndex->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabTaskName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabPointName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pRollerNo->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabItemName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabItemName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabBeginTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabActType->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabResult->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabAlarmVal->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabDeviceType->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pBtnImage->setStyleSheet("QPushButton:hover { background-color:  rgba(85, 255, 127,150); };background-color: transparent;color: rgb(255, 255, 255);border: none;");
		}
	};

	/**
	* @ Author: Gaojia
	* @ Description: 持续监测信息对象
	*/
	struct MyStructCotdetItem
	{
		QLabel    *     m_pLabIndex;     //序号
		QLabel    *     m_pLabTaskName;  //任务名称
		QLabel    *     m_pLabDeviceType;  //设备类型
		QLabel    *     m_pLabAlarmTime; //报警时间
		QLabel    *     m_pLabAlarmResult;   //报警值
		QLabel    *     m_pLabAlarmVal;  //报警阈值
		QLabel    *     m_pLabAlarmLoc;  //报警所在位置
		QLabel    *     m_pLabAlarmRpllerCode;  //报警所在托辊号
		QLabel    *     m_pBtnImage;     //预览图
		QPushButton *   m_pBtnView;      //查询明细
		MyStructCotdetItem()
		{
			m_pLabIndex = new QLabel();
			m_pLabTaskName = new QLabel();
			m_pLabDeviceType = new QLabel();
			m_pLabAlarmTime = new QLabel();
			m_pLabAlarmResult = new QLabel();
			m_pLabAlarmVal = new QLabel();
			m_pLabAlarmLoc = new QLabel();
			m_pLabAlarmRpllerCode = new QLabel();
			m_pBtnImage = new QLabel();
			m_pBtnView = new QPushButton();

			m_pLabIndex->setAlignment(Qt::AlignCenter);
			m_pLabTaskName->setAlignment(Qt::AlignCenter);
			m_pLabDeviceType->setAlignment(Qt::AlignCenter);
			m_pLabAlarmTime->setAlignment(Qt::AlignCenter);
			m_pLabAlarmResult->setAlignment(Qt::AlignCenter);
			m_pLabAlarmVal->setAlignment(Qt::AlignCenter);
			m_pLabAlarmLoc->setAlignment(Qt::AlignCenter);
			m_pLabAlarmRpllerCode->setAlignment(Qt::AlignCenter);
			m_pBtnImage->setAlignment(Qt::AlignCenter);
			m_pBtnView->setText(QString::fromLocal8Bit("查看明细"));

			m_pLabIndex->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabTaskName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabDeviceType->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabAlarmTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabAlarmResult->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabAlarmVal->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabAlarmLoc->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabAlarmRpllerCode->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pBtnImage->setStyleSheet("QPushButton:hover { background-color:  rgba(85, 255, 127,150); };background-color: transparent;color: rgb(255, 255, 255);border: none;");
		}
	};

	/**
	* @ Author: hanjiaxing
	* @ Description: AI报警记录查询
	*/
	struct MyStructAIAlarmItem
	{
		QLabel    *     m_pLabIndex;     //序号
		QLabel    *     m_pLabAlgName;  //算法名称
		QLabel    *     m_pLabCamerName;  //摄像头名称
		QLabel    *     m_pLabAlarmTime; //报警时间
		QLabel    *     m_pLabAlarmState;  //报警是否处理
		QLabel    *     m_pBtnImage;  //报警截图
		QPushButton *   m_pBtnView;      //查询明细
		MyStructAIAlarmItem()
		{
			m_pLabIndex = new QLabel();
			m_pLabAlgName = new QLabel();
			m_pLabCamerName = new QLabel();
			m_pLabAlarmTime = new QLabel();
			m_pLabAlarmState = new QLabel();
			m_pBtnImage = new QLabel();
			m_pBtnView = new QPushButton();

			m_pLabIndex->setAlignment(Qt::AlignCenter);
			m_pLabAlgName->setAlignment(Qt::AlignCenter);
			m_pLabCamerName->setAlignment(Qt::AlignCenter);
			m_pLabAlarmTime->setAlignment(Qt::AlignCenter);
			m_pLabAlarmState->setAlignment(Qt::AlignCenter);
			m_pBtnImage->setAlignment(Qt::AlignCenter);
			m_pBtnView->setText(QString::fromLocal8Bit("查看明细"));

			m_pLabIndex->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabAlgName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabCamerName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabAlarmTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabAlarmState->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pBtnImage->setStyleSheet("QPushButton:hover { background-color:  rgba(85, 255, 127,150); };background-color: transparent;color: rgb(255, 255, 255);border: none;");
		}
	};

	/**
	* @ Author: hanjiaxing
	* @ Description: 跑偏记录查询
	*/
	struct MyStructCorrectItem
	{
		QLabel    *     m_pLabIndex;     //序号
		QLabel    *     m_pLabPointName;  //点位名称
		QLabel    *     m_pLabStartTime;  //开始时间
		QLabel    *     m_pLabEndTime; //结束时间
		QLabel    *     m_pLeftValue;  //跑偏左侧值
		QLabel    *     m_pRightValue;  //跑偏右侧值
		QLabel    *     m_pAlarmDesc; //跑偏报警描述
		QLabel    *     m_pBtnImage;  //报警截图
		QPushButton *   m_pBtnView;      //查询明细
		MyStructCorrectItem()
		{
			m_pLabIndex = new QLabel();
			m_pLabPointName = new QLabel();
			m_pLabStartTime = new QLabel();
			m_pLabEndTime = new QLabel();
			m_pLeftValue = new QLabel();
			m_pRightValue = new QLabel();
			m_pAlarmDesc = new QLabel();
			m_pBtnImage = new QLabel();
			m_pBtnView = new QPushButton();

			m_pLabIndex->setAlignment(Qt::AlignCenter);
			m_pLabPointName->setAlignment(Qt::AlignCenter);
			m_pLabStartTime->setAlignment(Qt::AlignCenter);
			m_pLabEndTime->setAlignment(Qt::AlignCenter);
			m_pLeftValue->setAlignment(Qt::AlignCenter);
			m_pRightValue->setAlignment(Qt::AlignCenter);
			m_pAlarmDesc->setAlignment(Qt::AlignCenter);
			m_pBtnImage->setAlignment(Qt::AlignCenter);
			m_pBtnView->setText(QString::fromLocal8Bit("查看明细"));

			m_pLabIndex->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabPointName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabStartTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabEndTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLeftValue->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pRightValue->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pAlarmDesc->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pBtnImage->setStyleSheet("QPushButton:hover { background-color:  rgba(85, 255, 127,150); };background-color: transparent;color: rgb(255, 255, 255);border: none;");
		}
	};

	/**
	* @ Author: hanjiaxing
	* @ Description: 撕裂记录查询
	*/
	struct MyStructTearItem
	{
		QLabel    *     m_pLabIndex;     //序号
		QLabel    *     m_pLabPointName;  //点位名称
		QLabel    *     m_pLabStartTime;  //开始时间
		QLabel    *     m_pLabEndTime; //结束时间
		QLabel    *     m_pBtnImage;  //报警截图
		QPushButton *   m_pBtnView;      //查询明细
		MyStructTearItem()
		{
			m_pLabIndex = new QLabel();
			m_pLabPointName = new QLabel();
			m_pLabStartTime = new QLabel();
			m_pLabEndTime = new QLabel();
			m_pBtnImage = new QLabel();
			m_pBtnView = new QPushButton();

			m_pLabIndex->setAlignment(Qt::AlignCenter);
			m_pLabPointName->setAlignment(Qt::AlignCenter);
			m_pLabStartTime->setAlignment(Qt::AlignCenter);
			m_pLabEndTime->setAlignment(Qt::AlignCenter);
			m_pBtnImage->setAlignment(Qt::AlignCenter);
			m_pBtnView->setText(QString::fromLocal8Bit("查看明细"));

			m_pLabIndex->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabPointName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabStartTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabEndTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pBtnImage->setStyleSheet("QPushButton:hover { background-color:  rgba(85, 255, 127,150); };background-color: transparent;color: rgb(255, 255, 255);border: none;");
		}
	};

public:
	CTableWidgetB(QWidget *parent);
	~CTableWidgetB();
	void InitUi(int nType);//初始化界面
	void InitData(int nType, QVector<QVector<QString>>vecStr);          //表格类型  0任务  1巡检点 2巡检项
	void setSmallSceneType(int nSmallSceneType);//设置小场景类型
	QVector<QVector<QString>>m_vecvStr;
	QVector<MyStructTask> m_vecMyStructTask;
	QVector<MyStructPoint>m_vecMyStructPoint;
	QVector<MyStructItem>m_vecMyStructItem;
	int m_nDataType;//表格类型  0任务  1巡检点 2巡检项 3AI算法报警结果查询界面 4皮带跑偏结果查询
	QString m_sPageUuid;
public slots:
	void slotClickedShowTask();
	void slotClickedShowItem();
	void slotClickedShowPdfReport();//展示pdf报表
	void slotClickedShowSyncPdfReport();//展示pdf综合报表
	void slotClickedShowAIAlarmInfo();//展示AI报警信息
	void slotClickedShowImg();//展示图片
	void onImageDownloaded(QLabel* pLabel,QPixmap pixmap,QString sPageUuid);
	void slotReCreRobPdfRpt();//重新生成机器人报表

private:
	CPdfRptInterface *m_pRptInterface = nullptr;//报表接口
	int m_nSmallSceneType;//小场景类型

signals:
	void sigShowTask(QString sTaskExecGuid, QString sTaskName, QString sTaskExecDesc);
	void sigShowPdf(QString sPdfPath);//打开pdf报表信号
	void sigShowSyncPdf(QString sSyncPdfPath);//打开pdf综合报表
	void sigShowItem(QString sTaskName, QString sItemExecGuid, QString sItemName, QString sPointName, int nDeviceType, int nIsCotdet, int nItemTypeCode);//打开查询巡检项执行记录详情
	void sigShowAIAlarmInfo(QString sGuid);
	void sigShowImg(QString sHttpUrl);
};

#endif